<template>
  <el-dialog
      width="95%"
      title="表格预览"
      v-model="dialogVisible"
      append-to-body
      :before-close="onClose">
    <avue-crud v-if="option" :option="option" :data="dataSource">
    </avue-crud>
  </el-dialog>
</template>

<script>
import designTools from "components/form-design/utils/designTools";

export default {
  name: "formPreviewTable",
  data() {
    return {
      dialogVisible: false,
      dataSource: [],
      option: null,
    }
  },
  methods: {
    show(formOption) {
      if (!formOption.column || formOption.column.length < 1) {
        this.$message.error("没有需要展示的内容")
        return
      }
      formOption = designTools.designOptionToAvueOption(formOption)
      this.option = formOption;
      this.dialogVisible = true
    },
    onClose() {
      this.dialogVisible = false
      this.option = null;
    }
  }
}
</script>

<style scoped>

</style>
